package com.oop2.test2;

/**
 * Created by L.jp
 * Description:
 * User: 86189
 * Date: 2022-09-18
 * Time: 20:14
 */
public class Student {
    //属性：
    private int age;
    private String name;
    private String sex;
    //加入对应的setter和getter方法：
    public int getAge() {
        return age;
    }
    public void setAge(int age) {
        this.age = age;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getSex() {
        return sex;
    }
    public void setSex(String sex) {
        if("男".equals(sex) || "女".equals(sex) ){//sex是男 或者 是 女
            this.sex = sex;
        }else{
            this.sex = "男";
        }
    }
    //加入构造器：
    public Student(){
    }
    public Student(int age,String name,String sex){
        this.age = age;
        this.name = name;
        //this.sex = sex;
        this.setSex(sex);
    }
}